local zhabing = fk.CreateSkill {
  name = "water_zhabing",
}

Fk:loadTranslationTable{
  ["water_zhabing"] = "诈病",
  [":water_zhabing"] = "游戏开始时，获得3枚「隐忍」。每枚隐忍可抵消1次伤害。并回复一体力。回合开始时，若你没有「隐忍」，你获得】【夺权】【弑君】【禅让】。",
  ["@water_renren"] = "隐忍",
  ["#water_zhabing_gain"] = "你获得了3枚隐忍标记",
  ["#water_zhabing_awake"] = "你失去了所有隐忍，获得了【出山】【夺权】【弑君】【禅让】",
}

-- 游戏开始获得3枚隐忍
zhabing:addEffect(fk.GameStart, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self.name)
  end,
  on_cost = function(self, event, target, player, data)
    return true
    
  end,
  on_use = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@water_renren", 3)
  end,
})

-- 受到伤害时优先消耗隐忍并回复
zhabing:addEffect(fk.DamageInflicted, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self.name) and player:getMark("@water_renren") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:removePlayerMark(player, "@water_renren")
    player.room:recover{
      who = player,
      num = 1,
      recoverBy = player,
      skillName = self.name,
    }
    data:preventDamage()-- 伤害无效
  end,
})

-- 隐忍用完自动获得四技
zhabing:addEffect(fk.TurnStart, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self.name) and player:getMark("@water_renren") == 0 and not player:hasSkill("water_chushan")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local skills = {"water_duoquan", "water_shijun", "water_chanrang","water_chushan"}
    room:handleAddLoseSkills(player, table.concat(skills, "|"))
  end,
})

return zhabing 